The ReportObjects collection of a report Section object contains all report objects in that section. Report objects may be Text objects, Fields, Subreport objects, or Cross
Note: If you want to work with all report objects in a section, consult IReportObject in the Object Browser for a list of properties that are common to all report objects.
Usually, report objects can be addressed directly in your code based on their Name property.
However, if you intend to work with several objects in a section, you need to refer to them through a Section object in the report. The following code locates the last object in the last section of the report and assigns a value to a String variable based on the type of object it is.
Dim Report As New CrystalReport1
Dim sect As Section
Dim rptObject As Object
Dim objKind As String
Dim lastSectWithObject As Integer lastSectWithObject = Report.Sections.Count
Set sect = Report.Sections.Item(lastSectWithObject) Do While sect.ReportObjects.Count <= 0 lastSectWithObject = lastSectWithObject - 1
Set sect = Report.Sections.Item(lastSectWithObject) Loop Set rptObject = sect.ReportObjects.Item(sect.ReportObjects.Count) Select Case rptObject.Kind Case crBlobFieldObject
objKind = "BLOB field object" Case crBoxObject
objKind = "Box object" Case crCrossTabObject
objKind = "CrossTab object" Case crFieldObject
objKind = "Field object" Case crGraphObject
objKind = "Graph object" Case crLineObject
objKind = "Line object" Case crOleObject
objKind = "OLE object" Case crSubreportObject
objKind = "Subreport object" Case crTextObject
objKind = "Text object" Case Else
objKind = "Unknown object" End Select
Note: Instead of using the Item property as shown, you can reference a report object directly using its index, for example, ReportOptions(1). You can also reference it directly using its name property by including the report object name in quotes, for example, sect.ReportObjects("Field5") instead of sect.ReportObjects(1).
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |